home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr11
/
powerb5.zip
/
LENGTH.BAT
< prev
next >
Wrap
DOS Batch File
|
1993-06-01
|
834b
|
35 lines
@ECHO OFF
REM Make sure the STRING isn't empty
IF "%STRING%"=="" GOTO error
REM Add a sentinel at the end. The "block" character, ASCII
REM 254, can be obtained by typing "254" while holding down
REM the <Alt> key on your keyboard.
SET TEMPSTR=%STRING%■
REM Length is at least 1
SET LNGTH=1
REM DOS's batch language can't do math, so
REM increment counter using simple comparisons
:loop
REM Chop off the first character of the STRING
FOR %%Y IN (/%TEMPSTR%) DO SET TEMPSTR=%%Y
IF "%TEMPSTR%"=="■" GOTO done
IF %LNGTH%==8 GOTO error
IF %LNGTH%==7 SET LNGTH=8
IF %LNGTH%==6 SET LNGTH=7
IF %LNGTH%==5 SET LNGTH=6
IF %LNGTH%==4 SET LNGTH=5
IF %LNGTH%==3 SET LNGTH=4
IF %LNGTH%==2 SET LNGTH=3
IF %LNGTH%==1 SET LNGTH=2
GOTO loop
:error
SET LNGTH=?
:done
SET TEMPSTR=